//
//  DigitalMessage.h
//  GJDigitalSDK
//
//  Created by 吴棒棒 on 2021/10/30.
//

#import <Foundation/Foundation.h>
#import <WebRTC/WebRTC.h>

NS_ASSUME_NONNULL_BEGIN
@protocol DigitalMessageDelegate <NSObject>

@optional

/// 错误信息返回
/// @param error error
- (void)onError:(NSError *)error;

/// 用来显示视频
/// @param stream  获取Track
- (void)didAddStream:(RTCMediaStream *)stream;

/// 收到offer后生成自己的sdp，发给中端
/// @param sdp 自己的
- (void)sendXmppForSdp:(RTCSessionDescription *)sdp;

/// 设置本地视频界面
/// @param captureSession 视频信息
- (void)setCaptureSession:(AVCaptureSession *)captureSession;

/// webrtc回调的candidate，分批发给中端
/// @param candidate 用来合成sdp
- (void)didGenerateIceCandidate:(RTCIceCandidate *)candidate;

/// webrtc连接状态回调
/// @param state RTCIceConnectionState
- (void)didIceConnectionChange:(RTCIceConnectionState)state;
@end



@interface DigitalMessage : NSObject

@property (nonatomic, strong) RTCPeerConnectionFactory *factory;
@property (nonatomic, strong) RTCCameraVideoCapturer *videoCapturer;
@property (nonatomic, strong) RTCDataChannel* localDataChannel;
@property (nonatomic, strong) RTCAudioTrack *localAudioTrack;;
@property (nonatomic, strong) RTCPeerConnection *publisherPeerConnection;
@property (nonatomic, strong) RTCVideoTrack *localTrack;

@property (nonatomic, weak) id<DigitalMessageDelegate> delegate;



+ (DigitalMessage *)shareMessage;

- (void)initDigital;

/// 收到offer后，设置remote
/// @param handleId 每个人的标识，我们暂时没用到
/// @param jsep offer收到的sdp信息
- (void)onPublisherRemoteJsep:(NSNumber *)handleId dict:(NSDictionary *)jsep;
/// 添加candidate
- (void)addCandidate:(NSDictionary *)dic;
@end

NS_ASSUME_NONNULL_END
